<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="include/base.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" media="all">
	<link rel="stylesheet" type="text/css" href="../css/hou.css" media="all">
	<style type="text/css">
		.menu{
			background-color: #D9EDF7;
		}
	</style>
</head>
<body>
	<div class="container">
		<%@include file="include/top.jsp" %>
		<div class="content">
			<%@include file="include/left.jsp" %>
			
			<div class="right pull-right">
				<div class="navbar" style="width:790px;margin-bottom:0px;">
					<div class="navbar-inner">
					  <a class="brand" href="javascript:;">图书管理</a>
					</div>			
				</div>
				<c:choose>
					<c:when test="${msg==1001}">
						<div class="alert">
						  <button type="button" class="close" data-dismiss="alert">&times;</button>
						  <strong>该图书不能删除</strong>
						</div>
					</c:when>
					<c:when test="${msg==1002}">
						<div class="alert alert-success">
						  <button type="button" class="close" data-dismiss="alert">&times;</button>
						  <strong>删除成功</strong>
						</div>
					</c:when>
				</c:choose>
				<div class="well" style="padding:5px;">
					<table class="table table-striped" style="border:1px solid #ccc">
						<tbody style="padding:10px;">
							<tr>
								<td>#</td>
								<td style="width:100px;height:37px;">书名</td>
								<td>状态</td>
								<td style="width:40px;">售出数量</td>
								<td style="width:40px;">收藏数量</td>
								<td>库存</td>
								<td style="width:40px;">危险数量</td>
								<td>创建时间</td>
								<td>修改</td>
								<td>删除</td>
							</tr>
							<c:forEach items="${bookList}" var="book" varStatus="s">
								<tr>
									<td>${s.count}</td>
									<td style="width:100px;height:37px;">${book.bookName}</td>
									<td>${book.state}</td>
									<td>${book.saleNum}</td>
									<td>${book.favNum}</td>
									<td>${book.num}</td>
									<td>${book.dangerNum}</td>
									<td>${book.createtime}</td>
									<td><a href="/admin/modifyBook.action?id=${book.id}"><i class="icon-pencil"></i></a></td>
									<td><a href="#myModal${book.id}" class="del" role="button" class="btn" data-toggle="modal"><i class="icon-remove"></i></a></td>
 
									<!-- id和<a>中的id一致，给id一个变化的值：myModal${book.id} -->
									<div id="myModal${book.id}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									  <div class="modal-header">
									    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
									    <h3 id="myModalLabel">确定删除《${book.bookName}》吗？</h3>
									  </div>
									  <div class="modal-footer">
									    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
									    <a href="/admin/delBook.action?id=${book.id}" class="btn btn-primary">确定</a>
									  </div>
									</div>
									
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function(){
			/* $(".del").click(function(){
				var result=confirm("确定删除吗？");
				if(result){
					 这样去hidden中的值,只能取到第一个
					alert($(".hidden").val());
					location.href="/admin/delBook.action?id="+$(".hidden").val();
				}
			}); */
		});
	</script>
</body>
</html>